package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import java.time.LocalDateTime;
import com.edu.exam.enums.examination.paper.PaperProcessingTaskStatus;
import com.edu.exam.enums.ImageProcessingTaskType;

/**
 * 处理任务实体类
 *
 * 根据E-04-02图像处理子模块数据库设计实现
 * 存储图像处理任务的管理信息。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ProcessingTask {

    /**
     * 任务ID，主键
     */
    @Id
    @Column(name = "task_id", length = 64)
    private String taskId;

    /**
     * 任务名称
     */
    @Column(name = "task_name", length = 200, nullable = false)
    private String taskName;

    /**
     * 任务类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "task_type", length = 30, nullable = false)
    private ImageProcessingTaskType taskType;

    /**
     * 任务状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "task_status", length = 20, nullable = false)
    private PaperProcessingTaskStatus taskStatus;

    /**
     * 优先级
     */
    @Column(name = "priority_level")
    private Integer priorityLevel;

    /**
     * 批次ID
     */
    @Column(name = "batch_id", length = 64)
    private String batchId;

    // 任务统计
    /**
     * 总图像数
     */
    @Column(name = "total_images")
    private Integer totalImages;

    /**
     * 已处理图像数
     */
    @Column(name = "processed_images")
    private Integer processedImages;

    /**
     * 成功图像数
     */
    @Column(name = "successful_images")
    private Integer successfulImages;

    /**
     * 失败图像数
     */
    @Column(name = "failed_images")
    private Integer failedImages;

    /**
     * 跳过图像数
     */
    @Column(name = "skipped_images")
    private Integer skippedImages;

    // 时间信息
    /**
     * 计划开始时间
     */
    @Column(name = "scheduled_start_time")
    private LocalDateTime scheduledStartTime;

    /**
     * 实际开始时间
     */
    @Column(name = "actual_start_time")
    private LocalDateTime actualStartTime;

    /**
     * 预计结束时间
     */
    @Column(name = "estimated_end_time")
    private LocalDateTime estimatedEndTime;

    /**
     * 实际结束时间
     */
    @Column(name = "actual_end_time")
    private LocalDateTime actualEndTime;

    // 进度信息
    /**
     * 进度百分比
     */
    @Column(name = "progress_percentage", precision = 5, scale = 2)
    private Double progressPercentage;

    /**
     * 当前处理图像
     */
    @Column(name = "current_processing_image", length = 64)
    private String currentProcessingImage;

    /**
     * 预计剩余时间（秒）
     */
    @Column(name = "estimated_remaining_time")
    private Integer estimatedRemainingTime;

    // 配置信息
    /**
     * 处理配置ID
     */
    @Column(name = "processing_config_id", length = 64, nullable = false)
    private String processingConfigId;

    /**
     * 质量配置ID
     */
    @Column(name = "quality_config_id", length = 64)
    private String qualityConfigId;

    // 错误信息
    /**
     * 是否有错误
     */
    @Column(name = "has_errors")
    private Boolean hasErrors;

    /**
     * 错误摘要
     */
    @Column(name = "error_summary", columnDefinition = "TEXT")
    private String errorSummary;

    /**
     * 创建人
     */
    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createdTime;

    /**
     * 更新人
     */
    @Column(name = "updated_by", length = 64)
    private String updatedBy;

    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    /**
     * 版本号
     */
    @Column(name = "version")
    private Integer version;

  
    }